package com.dolphin.apiboss.controller;

import com.dolphin.apiboss.service.CarService;
import com.dolphin.apiboss.service.DriverUserService;
import com.dolphin.common.dto.Car;
import com.dolphin.common.dto.DriverUser;
import com.dolphin.common.dto.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class DriverUserController {

    @Autowired
    DriverUserService driverUserService;
    @Autowired
    CarService carService;

    /**
     * 添加司机
     * @param driverUser
     * @return
     */
    @PostMapping("/driver-user")
    public ResponseResult addDriverUser(@RequestBody  DriverUser driverUser){
        log.info("service-boss:driverUser:"+driverUser);

        ResponseResult responseResult = driverUserService.addDriverUser(driverUser);
        return responseResult;
    }

    /**
     * 修改司机
     * @param driverUser
     * @return
     */

    @PutMapping("/driver-user")
    public ResponseResult updateDriverUser(@RequestBody  DriverUser driverUser){
        log.info("service-boss:driverUser:"+driverUser);

        ResponseResult responseResult = driverUserService.updateDriverUser(driverUser);
        return responseResult;
    }

    @PostMapping("/car")
    public ResponseResult addCar(@RequestBody Car car) {
        return carService.addCar(car);
    }

}
